import java.util.Random;


class Car {
	private String licensePlate, owner, address;
	private Delict[] delictsList=new Delict[500];
	int delictsRegistered=0;
	
	public Car(String licensePlate, String owner, String address) {
		this.licensePlate = licensePlate;
		this.owner = owner;
		this.address = address;
	}

	public String getLicensePlate() {
		return licensePlate;
	}
	
	public String getOwner() {
		return owner;
	}
	
	public String getAddress() {
		return address;
	}

	public void registerDelict(Delict delict) {
		this.delictsList[delictsRegistered % 500]=delict;
		delictsRegistered++;
	}
	
	public Delict[] getDelicts() {
		return this.delictsList;
	}
	
}

class TrafficOffice {
	private static Car[] cars=new Car[1000];
	private static int carsRegistered=0;
	
	public void registerCar(Car car) {
		cars[carsRegistered % 1000]=car;
		carsRegistered++;
	}
	
	public Car getCar(String licensePlate){
		for (int i=0; i<(carsRegistered % 1000); i++){
            if (cars[i].getLicensePlate().equals(licensePlate)) return cars[i];
        }
		System.out.println("Car not registered!");
		return null;
	}
}

class Delict{
	private double fee;
	private int points;
	
	public Delict(double fee, int points){
		this.fee=fee;
		this.points=points;
	}
	
	public double getFee(){
		return fee;
	}
	
	public int getPoints(){
		return points;
	}
}

class TrafficWarden {
	private TrafficOffice office;
	private Car carToCheck;
	
	public TrafficWarden(TrafficOffice office) {
		this.office = office;
	}
	
	public void checkCar(String licensePlate) {
		this.carToCheck=office.getCar(licensePlate);
	}

	public void fine() {
		Random rand = new Random();
        carToCheck.registerDelict(new Delict(rand.nextDouble()*100, rand.nextInt(4)));
	}
	
	public void printTicket() {
		Delict[] delicts=carToCheck.getDelicts();
        double fees = 0;
        int points = 0;
        System.out.println("Strafzettel: " + carToCheck.getLicensePlate() + ", " + carToCheck.getOwner() + ", " + carToCheck.getAddress());
        for (int i=0; i<carToCheck.delictsRegistered; i++){
            fees += delicts[i].getFee();
            points += delicts[i].getPoints();
        }
        System.out.println("Insgesamt " + fees + " Gebuehren und " + points + " Punkte");
	}
	
}

public class Aufgabe5 {

	public static void main(String[] args) {
		Car karre1=new Car("A-BC 100", "Meier", "Hafenstr. 1");
		Car karre2=new Car("A-DD 102", "Mueller", "Landstr. 3");
		
		TrafficOffice TO1=new TrafficOffice();
		TrafficOffice TO2=new TrafficOffice();
		
		TO1.registerCar(karre1);
		TO2.registerCar(karre2);
		
		TrafficWarden warden1=new TrafficWarden(TO1);
		TrafficWarden warden2=new TrafficWarden(TO2);
		
		warden1.checkCar("A-BC 100");
		warden1.fine();
		warden1.printTicket();
		warden2.checkCar("A-DD 102");
		warden2.fine();
		warden2.printTicket();
		
		
	}

}
